package hy.mvpbeam.persenter.activitypersenter;

import android.support.annotation.NonNull;
import android.util.Log;

import com.jude.beam.expansion.list.BeamListActivityPresenter;

import hy.mvpbeam.activity.PictureListActivity;
import hy.mvpbeam.model.PictureModel;
import hy.mvpbeam.model.bean.PictureBean;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by hy on 2016/10/26.
 */

public class PictureListActivityPresenter extends BeamListActivityPresenter<PictureListActivity, PictureBean.TngouBean> {
    private static final String TAG = PictureListActivityPresenter.class.getSimpleName();
    @Override
    protected void onCreateView(@NonNull PictureListActivity view) {
        super.onCreateView(view);
        onRefresh();

    }

    @Override
    public void onRefresh() {
        super.onRefresh();

        PictureModel.getInstance().getPictureList(new Callback<PictureBean>() {
            @Override
            public void onResponse(Call<PictureBean> call, Response<PictureBean> response) {
                Log.d(TAG, "onResponse: " + response.body().toString());
                //数据获取完毕后，将数据填充到view
                getRefreshSubscriber().onNext(response.body().getTngou());
            }


            @Override
            public void onFailure(Call<PictureBean> call, Throwable t) {
                Log.d(TAG, "onFailure: ");
            }
        });
    }

    @Override
    public void onLoadMore() {
        super.onLoadMore();


    }
}
